﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _3.ConvertDecimalToHex
{
    class ConvertDecimalToHex
    {
        static void Main()
        {
            Console.WriteLine();
            Console.WriteLine("Input decimal number or 0 to exit:");

            int dec = int.Parse(Console.ReadLine());
            if (dec > 0)
            {
                StringBuilder hex = new StringBuilder();
                while (dec > 0)
                {
                    switch (dec % 16)
                    {
                        case 10:
                            hex.Append('A');
                            break;
                        case 11:
                            hex.Append('B');
                            break;
                        case 12:
                            hex.Append('C');
                            break;
                        case 13:
                            hex.Append('D');
                            break;
                        case 14:
                            hex.Append('E');
                            break;
                        case 15:
                            hex.Append('F');
                            break;
                        default:
                            hex.Append(dec % 16);
                            break;
                    }
                    dec = dec / 16;
                }
                string number = hex.ToString();
                for (int i = number.Length - 1; i > -1; i--)
                {
                    Console.Write(number[i]);
                }
                
                Main();
            }
            else
            {
                Console.WriteLine("BYE!");
            }
        }
    }
}